package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.LessonData;
import com.thinkcube.edutainment.service.viewitem.MyLessonItem;
import com.thinkcube.edutainment.service.viewitem.MyLessonItem_;



@EBean
public class MyLessonAdapter extends BaseAdapter {

	List<LessonData> lessonDatList;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		MyLessonItem myLessonItem;
		if (convertView == null) {
			myLessonItem = MyLessonItem_.build(context);
		} else {
			myLessonItem = (MyLessonItem) convertView;
		}

		myLessonItem.bind(getItem(position));

		return myLessonItem;
	}

	public List<LessonData> getLessonDatList() {
		return lessonDatList;
	}

	public void setLessonDatList(List<LessonData> lessonDatList) {
		this.lessonDatList = lessonDatList;
	}

	@Override
	public int getCount() {
		return lessonDatList.size();
	}

	@Override
	public LessonData getItem(final int position) {
		return lessonDatList.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
